package dressSmart.modules.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import dressSmart.common.api.CommonResult;
import dressSmart.modules.model.Clothes;
import dressSmart.modules.service.ClothesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author znx
 * @since 2022-11-11
 */
@RestController
@RequestMapping("/clothes")
public class ClothesController {

    @Autowired
    private ClothesService clothesService;

    /**
     *
     * @param tagId 标签id 根据标签id查询衣服 可以不填
     * @param userId 根据用户id查询他的衣服
     *               两个不填为所有衣服
     * @param timeSort  0更新时间降序排列  1更新时间升序排列
     *
     * @return
     */
    @GetMapping("/list")
    public CommonResult list(@RequestParam(value = "tagId",required = false) Integer tagId,
                             @RequestParam(value = "userId",required = false) Integer userId,
                             @RequestParam(value = "timeSort",defaultValue = "0") Integer timeSort){

        List<Clothes> clothesList=clothesService.getList(tagId,userId,timeSort);
        return CommonResult.success(clothesList);
    }

    
    
    

}

